home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / fulcom.zip / FULCOM.PAS < prev   
Pascal/Delphi Source File  |  1986-09-16  |  3KB  |  92 lines

  1.  
  2.  { main file FULCOM.PAS}
  3.  { IBM and TI compatible comm port procedures}
  4.  
  5.  {
  6.  This  is  a  dumb-terminal program to test the two include files FULCOM.IBM
  7.  and  FULCOM.TIP.  These  include  files  contain  a  set of  procedures and
  8.  functions  that  are identical to the programmer, but operate the different
  9.  hardware  on the Texas Instruments Professional Computer and the IBM PC/XT.
  10.  This  enables  a  programmer  to  program  a application program for either
  11.  computer by including the appropriate file.
  12.  
  13.  The  program  features  both input and OUTPUT buffering, handy when you are
  14.  using  the comm ports to drive a terminal or other device in a applications
  15.  type of program.
  16.  
  17.  
  18.  Enter  the appropiate port parameters in the marked statement. To exit this
  19.  program, press the "ESC" key.  To toggle the state of the DTR  line,  press
  20.  the "!" key.
  21.  }
  22.  
  23.  
  24. program FULCOM;
  25.  
  26. type WorkLineType=string[255];
  27.  
  28. var Loop:boolean;
  29.     TempString:WorkLineType;
  30.     InChar:char;
  31.     OldCTSStatus:boolean;
  32.     OldDCDStatus:boolean;
  33.     DTRStatus:boolean;
  34.     ComPort:byte;
  35.     RegisterSet:record case integer of
  36.          1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags:integer);
  37.          2: (AL,AH,BL,BH,CL,CH,DL,DH:byte);
  38.          end;
  39.     DSstorage:integer absolute CSeg:$00A0;
  40.  
  41. (*************  comment out the appropiate include file  ****************)
  42. (*{$IFULCOM.TIP}*)
  43. {$IFULCOM.IBM}
  44. (************************************************************************)
  45.  
  46. begin
  47.     DSStorage:=dseg;
  48.     (******* place the port parameters here   ***
  49.      * ComPort= port number (1 or 2)            *
  50.      * Baud (300,1200,2400,4800,9600)           *
  51.      * Parity (E=even O=Odd N=none)             *
  52.      * WordSize (7 or 8)                        *
  53.      * StopBits (1 or 2)                        *
  54.      ********************************************)
  55.     ComPort:=1;
  56.     INITCOM(ComPort,1200,'O',7,1);
  57.     (***************************************************)
  58.     Loop:=true;
  59.     OldCTSStatus:=false;
  60.     OldDCDStatus:=false;
  61.     DTRStatus:=true;
  62.     clrscr;
  63.     while Loop do begin
  64.          if CTSStatus(ComPort)<>OldCTSStatus then begin
  65.               OldCTSStatus:=CTSSTATUS(ComPort);
  66.               write(#7' CTS STATUS CHANGE (',OldCTSStatus,') ');
  67.               end;
  68.          if DCDStatus(ComPort)<>OldDCDStatus then begin
  69.               OldDCDStatus:=DCDSTATUS(ComPort);
  70.               write(#7' DCD STATUS CHANGE (',OldDCDStatus,') ');
  71.               end;
  72.          if not(BUFFEREMPTY(InputBuffer[ComPort])) then begin
  73.               InChar:=chr(READBUFFER(InputBuffer[ComPort]));
  74.               write(InChar);
  75.               end;
  76.          if keypressed then begin
  77.               read(kbd,InChar);
  78.               case Inchar of
  79.                    #27:Loop:=false;
  80.                    '!':begin
  81.                         DTRStatus:=not(DTRStatus);
  82.                         TXControl(ComPort,DTRStatus);
  83.                         end;
  84.                    else begin
  85.                         TempString:=InChar;
  86.                         SENDSTRING(ComPort,TempString);
  87.                         end;
  88.                    end;
  89.               end;
  90.          end;
  91.     TERMINATECOM(ComPort);
  92.     end.